//
//  SWEventsFetchReq.swift
//  ChildStory
//
//  Created by linhan on 2016/11/11.
//  Copyright © 2016年 Aiya. All rights reserved.
//

import Foundation

class SWEventsFetchReq: SWBaseRequest
{
    var stageID:String = ""
    
    override init()
    {
        super.init()
        api = SWRequestAPI.EventsFetch
    }
    
    override var params:Any?
    {
        return ["timeId":stageID]
    }
    
    override func JSONToModel(_ json:JSON, JSONString:String, JSONData:Data) -> AnyObject?
    {
        return Mapper<SWEventsFetchRsp>().map(JSONString: JSONString)
    }
}

class SWEventsFetchRsp: NSObject,Mappable
{
    var events:[SWEventRsp]?
    var comingEvents:[SWEventRsp]?
    var code:String?
    var count:Int?
    required init?(map: Map) { }
    
    func mapping(map: Map) {
        code        <- map["Status"]
        events  <- map["BaseModle.bigcase"]
        count  <- map["BaseModle.totalCount"]
        comingEvents  <- map["BaseModle.front"]
    }
}

class SWBaseEventRsp: NSObject,Mappable
{
    var title:String?
    var summary:String?
    var eventID:Int?
    var type:Int?
    var coverURL:String?
    var majorExampleURL:String?
    var isFavorite:Int?
    required init?(map: Map) { }
    
    func mapping(map: Map) {
        title       <- map["title"]
        summary     <- map["summary"]
        eventID     <- map["caseId"]
        type        <- map["typeId"]
        coverURL    <- map["cover_url"]
        majorExampleURL    <- map["imageDefault"]
        isFavorite  <- map["isCollected"]
    }
}


class SWEventRsp: SWBaseEventRsp
{
    var features:[SWEventFeatureRsp]?
    
    override func mapping(map: Map) {
        super.mapping(map: map)
        features         <- map["taglist"]
    }
}

class SWEventFeatureRsp: NSObject,Mappable
{
    var title:String?
    var id:Int?
    var content:String?
    
    required init?(map: Map) { }
    
    // Mappable
    func mapping(map: Map) {
        id        <- map["tagId"]
        title        <- map["tagName"]
        content      <- map["tagContent"]
    }
}
